#pragma once

#include "../RHIResource.h"

class RHISampler : public RHIResource
{
	friend class RenderState;

	struct BuilderDetails {

		VkSamplerCreateInfo samplerCreateInfo;

		BuilderDetails();
	};

public:

	class Builder : public BuilderBase<BuilderDetails> {
		friend struct BuilderDetails;
	public:
		Builder() noexcept;
		Builder(Builder const& rhs) noexcept;
		Builder(Builder&& rhs) noexcept;
		~Builder() noexcept;
		Builder& operator=(Builder const& rhs) noexcept;
		Builder& operator=(Builder&& rhs) noexcept;

		Builder& SetMagFilter(VkFilter magFilter) noexcept;
		Builder& SetMinFilter(VkFilter minFilter) noexcept;
		Builder& SetMipmapMode(VkSamplerMipmapMode mipmapMode) noexcept;
		Builder& SetAddressMode(VkSamplerAddressMode addressMode) noexcept;
		Builder& SetAddressModeU(VkSamplerAddressMode addressModeU) noexcept;
		Builder& SetAddressModeV(VkSamplerAddressMode addressModeV) noexcept;
		Builder& SetAddressModeW(VkSamplerAddressMode addressModeW) noexcept;
		Builder& SetMipLodBias(float mipLodBias) noexcept;
		Builder& SetAnisotropyEnable(VkBool32 anisotropyEnable) noexcept;
		Builder& SetCompareEnable(VkBool32 compareEnable) noexcept;
		Builder& SetCompareOp(VkCompareOp compareOp) noexcept;
		Builder& SetMinLod(float minLod) noexcept;
		Builder& SetMaxLod(float maxLod) noexcept;
		Builder& SetBorderColor(VkBorderColor borderColor) noexcept;
		Builder& SetUnnormalizedCoordinates(VkBool32 unnormalizedCoordinates) noexcept;
		Builder& SetMaxAnisotropy(float maxAnisotropy) noexcept;

		RefCountPtr<RHISampler> Build();
		RefCountPtr<RHISampler> Build(RenderProcess* process, const std::string& name);

		uint32 GetHash() const;

	private:
		friend class RHISampler;
	};

	RHISampler(BuilderDetails& builderDetails);

	virtual void ReleaseResource() override;

	virtual ~RHISampler();

	VkSampler GetSampler() const;

protected:

	VkSampler mSampler;
};
